// http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.window.Window.html
Ext.require('Ext.chart.*');
Ext.require(['Ext.layout.container.Fit', 'Ext.window.MessageBox']);
Ext.define('EUniversitySuperAdmin.view.analyticboard.chartboard', {

    extend :    'Ext.panel.Panel'
    	
    	
  , alias :     'widget.chartboard'
  , title :     'Analytic chart'
  , layout :    'fit'
  , width: 300
  , height: 200
  , autoShow :  true
  ,store:{}
  , initComponent : function () {
	  
	  //var datastore=Ext.JSON.decode(globalStore);
	  
	  var datastore = {
  			fields:Ext.JSON.decode(globalHeaderjson),
  			data:Ext.JSON.decode(globalStore)
  			
  	};
    this.items = [
      {
            xtype: 'chart',
            id: 'chartCmp',
            animate: true,
            store:datastore ,
            shadow: true,
            legend: {
                position: 'right'
            },
            insetPadding: 60,
            theme: 'Base:gradients',
            series: [{
                type: 'pie',
                field: 'nombreforum',
                showInLegend: true,
                donut: true,
                tips: {
                  trackMouse: true,
                  width: 140,
                  height: 28,
                  renderer: function(storeItem, item)
                  {
                    //calculate percentage.
                    var total = 0;
                    datastore.each(function(rec) {
                        total += parseFloat(rec.get('nombreforum'));
                        alert(total);
                    });
                    total=4;
                    this.setTitle(storeItem.get('Prenom') + ': ' + Math.round(parseFloat(storeItem.get('nombreforum')) / total * 100) + '%');
                  }
                },
                highlight: {
                  segment: {
                    margin: 20
                  }
                },
                label: {
                    field: 'namecours',
                    display: 'rotate',
                    contrast: true,
                    font: '18px Arial'
                }
            }]
        }
    ]; 

   
    this.callParent(arguments);

  } // initComponent
});